#include "FileUtil.h"
#include <QDir>
#include <QDirIterator>
#include <QStringList>

std::vector<std::string> FileUtil::searchFiles(std::string path, std::string nameFilter)
{
	QString pathq = QString::fromStdString(path);
	QString nameFilterq = QString::fromStdString(nameFilter);
	QDirIterator dir_it(pathq, QStringList() << nameFilterq, QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
	std::vector<std::string> result;
	while (dir_it.hasNext())
	{
		dir_it.next();
		QString pp = dir_it.fileInfo().absoluteFilePath();
		result.push_back(pp.toStdString());
	}
	return result;
	//QString path = "E:/data/ZZDX3D_OSGB/OSGB/*/*L22*.osgb";
	//QDir dir("E:/data/ZZDX3D_OSGB/OSGB/Data/");
	//QStringList pattern = { "*L22*.osgb" };
	//QStringList files;
	//while (dir_it.hasNext())
	//{
	//	dir_it.next();
	//	files.append(dir_it.fileInfo().absoluteFilePath());
	//}
	//files.append("");
}
